package com.sharepics.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.sharepics.R;
import com.sharepics.bean.Album;
import com.sharepics.db.AlbumDAO;

public class EditAlbum extends Activity{

	EditText albumname;
	private Button saveButton;
	private Button startAlbumButton;
	private AlbumDAO albumDAO;
	private Album album;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.edit_album);
		albumname = (EditText) findViewById(R.id.albumname);
        saveButton = (Button) findViewById(R.id.saveButton);
        this.saveButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                saveAlbum();
            }
        });
        
        long albumId = getIntent().getLongExtra("com.myroad.ui.albumId", -1);
        album = albumDAO.get(albumId);
        albumname.setText(album.name);
        
        startAlbumButton = (Button) findViewById(R.id.startAlbumButton);
        startAlbumButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
               
            }
        });
	}
	
    private void saveAlbum() {
    	
    	album.name = albumname.getText().toString();
    	albumDAO.update(album);
    	setResult(Activity.RESULT_OK);
    	finish();
    }
	
}
